//
// Created by apple on 2022/9/24.
//

#ifndef MATRIX_MATRIX_H
#define MATRIX_MATRIX_H

#include <cstdlib>
#include <random>
#include <iostream>
#include <cassert>
#include <thread>

#define BLOCK_SIZE 64
const auto THREAD_NUM = (int) std::max(std::thread::hardware_concurrency() - 1, (unsigned int) 1);

class Matrix {
public:
    Matrix(int nRow, int nCol);

    ~Matrix() { delete data; }

    Matrix *setRandom();

    Matrix *setZero();

    Matrix *transpose() const;


    void print(const std::string &end = "\n") const;

    float *data;

    int nRow() const { return _nRow; }

    int nCol() const { return _nCol; }

private:
    int _nRow, _nCol;
};


Matrix *matmulBaseline(Matrix *A, Matrix *B);

Matrix *matmulWinergrad(Matrix *A, Matrix *B);

Matrix *matmulBaselineMultiThread(Matrix *A, Matrix *B);


Matrix *matmulIKJ(Matrix *A, Matrix *B);
Matrix *matmulIKJWinergrad(Matrix *A, Matrix *B);
Matrix *matmulIKJMultiThread(Matrix *A, Matrix *B);

Matrix *matmulBlock(Matrix *A, Matrix *B);
Matrix *matmulBlockWinergrad(Matrix *A, Matrix *B);
Matrix *matmulBlockMultiTread(Matrix *A, Matrix *B);

#endif //MATRIX_MATRIX_H
